package com.killer.goods.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.killer.db.service.impl.BaseServiceImpl;
import com.killer.goods.entity.CategoryBrand;
import com.killer.goods.mapper.CategoryBrandMapper;
import com.killer.goods.service.ICategoryBrandService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 分类品牌中间表 服务实现类
 * </p>
 *
 * @author killer
 * @since 2021-08-04
 */
@Service
public class CategoryBrandServiceImpl extends BaseServiceImpl<CategoryBrandMapper, CategoryBrand> implements ICategoryBrandService {

    @Override
    protected LambdaQueryWrapper<CategoryBrand> createQueryWrapper(Map<String, Object> searchMap) {
        LambdaQueryWrapper<CategoryBrand> queryWrapper = Wrappers.lambdaQuery(CategoryBrand.class);
        if (searchMap != null) {
            queryWrapper.eq(searchMap.get("brandId") != null, CategoryBrand::getBrandId, searchMap.get("brandId"));
            queryWrapper.eq(searchMap.get("categoryId") != null, CategoryBrand::getCategoryId, searchMap.get("categoryId"));
        }

        return super.createQueryWrapper(searchMap);
    }

}
